

SECTION .text
BITS 32

	
GLOBAL vector0, vector1, vector2, vector3, vector4, vector5, vector6, vector7, vector8, vector9, vector10, vector11, vector12, vector13, vector14, vector15, vector16, vector17, vector18, vector19, vector_reserved, vector32, vector33


%ifdef DEBUG
EXTERN printf	
rece_int_sig : db 'Receive a interrupt with vector %d\n', 0
%endif


	;; Divide Error
vector0:
%ifdef DEBUG
	push dword 0
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	iret


	;; Reserved
vector1:
%ifdef DEBUG
	push dword 1
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	iret


	;; NMI Interrupt
vector2:
	
%ifdef DEBUG
	push dword 2
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


	;; Breakpoint INT 3
vector3:	
	
%ifdef DEBUG
	push dword 3
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


	;; Overflow INTO
vector4:	
	
%ifdef DEBUG
	push dword 4
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret



	;; BOUND Range Exceeded BOUND
vector5:	
	
%ifdef DEBUG
	push dword 5
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


	;; Invalid Opcode 
vector6:	
	
%ifdef DEBUG
	push dword 6
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


	;; Decvice Not Available
vector7:	
	
%ifdef DEBUG
	push dword 7
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


	;; Double Fault
vector8:	
	
%ifdef DEBUG
	push dword 8
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	iret


	;; Coprocessor Segment Overrun
vector9:	
	
%ifdef DEBUG
	push dword 9
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector10:	
	
%ifdef DEBUG
	push dword 10
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector11:	
	
%ifdef DEBUG
	push dword 11
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector12:	
	
%ifdef DEBUG
	push dword 12
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector13:	
	
%ifdef DEBUG
	push dword 13
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector14:	
	
%ifdef DEBUG
	push dword 14
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector15:	
	
%ifdef DEBUG
	push dword 15
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector16:	
	
%ifdef DEBUG
	push dword 16
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector17:	
	
%ifdef DEBUG
	push dword 17
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector18:	
	
%ifdef DEBUG
	push dword 18
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret
	
vector19:	
	
%ifdef DEBUG
	push dword 19
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


vector_reserved:
%ifdef DEBUG
	push dword 32
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


vector32:
%ifdef DEBUG
	push dword 32
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	
	iret


vector33:
	cli
	pusha
	
%ifdef DEBUG
	push dword 31
	push dword rece_int_sig
	call printf
	add esp, 8
%endif
	xor eax, eax
	in al, 0x60
	push eax
EXTERN keyboard_interrupt
	call keyboard_interrupt
	add esp, 4

	;; 发送 EOI 给 IOAPIC，准备接受下次中断
	mov eax, 0x0
	mov [0xfee0_00b0], eax
	
	popa
	sti
	iret
